package main

import "fmt"

type Animaler interface {
	SetName(string)
	GetName() string
}

// 结构体值类型
type Dog struct {
	name string
}

func (d *Dog) SetName(name string) {
	d.name = name
}

func (d Dog) GetName() string {
	return d.name
}

type Cat struct {
	name string
}

func (d *Cat) SetName(name string) {
	d.name = name
}

func (d Cat) GetName() string {
	return d.name
}

func main() {
	a := &Dog{
		"露露",
	}

	fmt.Println(a.GetName())
	a.SetName("test")
	fmt.Println(a.GetName())

	var b Animaler = a
	b.SetName("test")
	fmt.Println(b.GetName())

	var c Animaler = a
	fmt.Println(c.GetName())

	c.SetName("test")
	fmt.Println(c.GetName())
}
